<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.util.List" %>
<%@ page import="lv.dysnomia.server.entities.MediaFile" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<fmt:setLocale value="${currentLocale}"/>
<fmt:setBundle basename="messages"/>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link type="text/css" rel="stylesheet" href="../style/style.css"/>
<title><fmt:message key="listmedia.title"/></title>
</head>
<body>
<%@ include file="../simple/navbar.jsp" %>
<%@ include file="../simple/filters.jsp" %>


<div class="content">
<h1><fmt:message key="listmedia.title"/></h1>

<table>
<tr>
<th>Fails</th>
<th>MIME</th>
<th>Baiti</th>
<th>Iesūtītājs</th>
<th>Fails'</th>
<th>Datums</th>
<th>Darbības</th>
</tr>
<%
int count = 0;
%>
<c:forEach items="${mediaInfos}" var="mediaInfo" varStatus="status">
<c:url value="/servlet/serve-blob" var="url">
<c:param name="blob-key" value="${mediaInfo.blobKey.keyString}"/>
</c:url>
<c:url value="/admin/delete-blob.html" var="deleteUrl">
<c:param name="blob-key" value="${mediaInfo.blobKey.keyString}"/>
</c:url>

<tr>
<td><c:out value="${status.count}" />. <a href="<c:out value="${url}"/>"><c:out
value="${mediaInfo.filename}" escapeXml="false" /></a></td>
<td><c:out value="${mediaInfo.contentType}"/></td>
<td><c:out value="${mediaInfo.size}"/></td>
<td><%
List<MediaFile> mFiles = (List<MediaFile>)request.getAttribute("mediaFiles");
MediaFile mFile = mFiles.get(count);
out.println(mFile.getAuthor());
count++;
%></td>
<td><%= mFile.getFileName() %></td>
<td><fmt:formatDate pattern="yyyy-MM-dd" value="${mediaInfo.creation}" /></td>
<td><a href="<c:out value="${deleteUrl}"/>">Dzēst</a></td>
</tr>
</c:forEach>
</table>

</div>
</body>
</html>